import type { TableColumn } from '@/components/core/dynamic-table';

export type TableListItem = API.UserListPageResultItem;
export type TableColumnItem = TableColumn<TableListItem>;

const operationParams = [
  {
    label: '草稿',
    value: 1,
  },
  {
    label: '审核中',
    value: 2,
  },
  {
    label: '已审核',
    value: 3,
  },
];
const operationParams2 = [
  {
    label: '领用申请',
    value: 1,
  },
  {
    label: '退还申请',
    value: 2,
  },
];

export const baseColumns: TableColumn[] = [
  {
    title: '关键字',
    align: 'left',
    dataIndex: 'keyword',
    hideInTable: true,
    formItemProps: {
      labelWidth: 55,
      componentProps: () => {
        return {
          placeholder: '可输入申请单号、申请人姓名搜索',
          disabledLabelWidth: true,
        };
      },
    },
  },
  {
    title: '申请类型',
    align: 'left',
    dataIndex: 'type2',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams2,
      },
    },
    customRender: ({ record }) =>
      operationParams2.filter((item) => item.value == record.type2)[0].label,
  },
  {
    title: '申请单号',
    align: 'left',
    dataIndex: 'userNum',
    hideInSearch: true,
  },
  {
    title: '申请状态',
    align: 'left',
    dataIndex: 'type',
    formItemProps: {
      component: 'Select',
      componentProps: {
        options: operationParams,
      },
    },
    customRender: ({ record }) =>
      operationParams.filter((item) => item.value == record.type)[0].label,
  },
  {
    title: '时间筛选',
    dataIndex: 'time',
    hideInTable: true,
    formItemProps: {
      component: 'RangePicker',
      componentProps: () => {
        return {
          format: 'YYYY/MM/DD HH:mm:ss',
          valueFormat: 'YYYY/MM/DD HH:mm:ss',
          showTime: true,
        };
      },
    },
  },

  {
    title: '申请总数量',
    align: 'left',
    dataIndex: 'userName',
    hideInSearch: true,
  },
  {
    title: '申请总价值',
    align: 'left',
    dataIndex: 'action',
    hideInSearch: true,
  },
  {
    title: '申请人',
    align: 'left',
    dataIndex: 'operationTime',
    hideInSearch: true,
  },
  {
    title: '申请时间',
    align: 'left',
    dataIndex: 'operationName',
    hideInSearch: true,
  },
];
